/**
 * simplex - a lab about simplex noise
 */

define('simplex', ['element', 'math'], function (element, math) {
    'use strict';
    
    var size = 600,
        f = 0.01,
        x, y = size,
        canvas = element.create('canvas', {parent:document.body, attr:{
            width: size, height: size}}),
        ctx = canvas.getContext('2d'),
        frame = ctx.getImageData(0, 0, size, size),
        start = (new Date).getTime(),
        n,
        i;
    
    
    while (y--) {
        x = size;
        while (x--) {
           n = noise.simplex3d(x * f, y * f, 0);
           i = 4 * (y * size + x);
           frame.data[i++] = 205 + 50 * n;
           frame.data[i++] = 205 + 50 * n;
           frame.data[i++] = 205 + 50 * n;  
           frame.data[i] = 255;
        }
    }
    
    ctx.putImageData(frame, 0, 0);
    
    console.log('time: ' + ((new Date).getTime() - start));

});
